import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../pages/HomePage.vue'
import UserLoginPage from '@/pages/user/UserLoginPage.vue'
import UserRegisterPage from '@/pages/user/UserRegisterPage.vue'
import UserManagePage from '@/pages/admin/UserManagePage.vue'
import AddPicturePage from '@/pages/AddPicturePage.vue'
import PictureManagePage from '@/pages/admin/PictureManagePage.vue'
import PictureDetailPage from '@/pages/PictureDetailPage.vue'
import AddPictureBatchPage from '@/pages/AddPictureBatchPage.vue'
import EmptyPage from '@/pages/EmptyPage.vue'
import UserUpdatePage from '@/pages/user/UserUpdatePage.vue'
import TestPage from '@/pages/TestPage.vue'
import SpaceManagePage from "@/pages/admin/SpaceManagePage.vue";
import AddSpacePage from "@/pages/AddSpacePage.vue";
import MySpacePage from "@/pages/MySpacePage.vue";
import SpaceDetailPage from "@/pages/SpaceDetailPage.vue";
import SearchPicturePage from "@/pages/SearchPicturePage.vue";
import SpaceAnalyzePage from "@/pages/SpaceAnalyzePage.vue";
import SpaceUserManagePage from "@/pages/admin/SpaceUserManagePage.vue";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/test',
      name: 'test',
      component: TestPage,
    },
    {
      path: '/admin/userManage',
      name: '用户管理',
      component: UserManagePage,
    },
    {
      path: '/user/update',
      name: '个人信息修改',
      component: UserUpdatePage,
    },
    {
      path: '/admin/pictureManage',
      name: '图片管理',
      component: PictureManagePage,
    },
    {
      path: '/admin/spaceManage',
      name: '空间管理',
      component: SpaceManagePage,
    },
    {
      path: '/spaceUserManage/:id',
      name: '空间成员管理',
      component: SpaceUserManagePage,
      props: true,
    },
    {
      path: '/add_picture',
      name: '图片上传',
      component: AddPicturePage,
    },
    {
      path: '/add_space',
      name: '创建空间',
      component: AddSpacePage,
    },
    {
      path: '/my_space',
      name: '我的空间',
      component: MySpacePage,
    },
    {
      path: '/space/:id',
      name: '空间详情',
      component: SpaceDetailPage,
      props: true,
      meta: { activeMenu: '/my_space' }, // 添加元信息标识关联菜单
    },
    {
      path: '/add_picture/batch',
      name: '批量创建图片',
      component: AddPictureBatchPage,
    },
    {
      path: '/picture/:id',
      name: '图片详情',
      component: PictureDetailPage,
      props: true,
    },
    {
      path: '/space_analyze',
      name: '空间分析',
      component: SpaceAnalyzePage,
    },
    {
      path: '/search_picture',
      name: '图片搜索',
      component: SearchPicturePage,
    },
    {
      path: '/not_found',
      name: '404',
      component: EmptyPage,
    },
    {
      path: '/:pathMatch(.*)*',
      redirect: '/not_found',
    },
  ],
})

export default router
